﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows.Data;
using System.Windows;
using System.Globalization;

namespace Jbe.TestSuite.Infrastructure.Shell.Presentation
{
    public class BoolToCollapsedConverter : IValueConverter
    {
        private static readonly BoolToCollapsedConverter @default = new BoolToCollapsedConverter();

        public static BoolToCollapsedConverter Default { get { return @default; } }

        
        public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
        {
            if (value is bool)
            {
                bool boolValue = (bool)value;

                if (parameter is string && ((string)parameter).Equals("Inverse", StringComparison.InvariantCultureIgnoreCase))
                {
                    boolValue = !boolValue;
                }
            
                return boolValue ? Visibility.Collapsed : Visibility.Visible;
            }
            throw new NotSupportedException();
        }

        public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
        {
            throw new NotImplementedException();
        }
    }
}
